home *** CD-ROM | disk | FTP | other *** search
/ Star Trek Starfleet Academy Mini Omnipedia / MINI_OMNI.ISO / pc / omni_v2.dxr / 00404_CONSTRUCTORS building FT indexes.ls < prev    next >
Encoding:
Text File  |  1996-04-15  |  10.2 KB  |  329 lines

  1. global gstepcounter, gmedialist, gWriteObject, gFTindexS, gdontfind1, gAlphText, gtheText, gAlphTextNew, glTheProp, gTextIndexA, gShortLongName, gReadObject, gEntireNameList, gGlobalStepCount, gdontfind3, gdontfind2, gLocalStepCount
  2.  
  3. on hTestEntryNamesMatch
  4.   set vtempList to [:]
  5.   set hold to []
  6.   set vCurrentList to [:]
  7.   set gEntireNameList to [:]
  8.   repeat with vCountCastMem = 513 to 540
  9.     set vtempList to the text of cast vCountCastMem
  10.     set vtempList to value(vtempList)
  11.     repeat with p = 1 to count(vtempList)
  12.       addProp(gEntireNameList, getPropAt(vtempList, p), getAt(vtempList, p))
  13.     end repeat
  14.   end repeat
  15.   set gEntireNameList to value(gEntireNameList)
  16.   sort(gEntireNameList)
  17.   set vCurrentList to value(vCurrentList)
  18.   sort(vCurrentList)
  19.   repeat with vCountCastMem = 663 to 782
  20.     set vCurrentList to the text of cast vCountCastMem
  21.     set vCurrentList to value(vCurrentList)
  22.     sort(vCurrentList)
  23.     set maxcount to count(vCurrentList)
  24.     set entryname to hChangeOneEntry(getPropAt(vCurrentList, 1), gEntireNameList)
  25.     repeat with n = 2 to maxcount
  26.       set entryname to hChangeOneEntry(getPropAt(vCurrentList, n), gEntireNameList)
  27.     end repeat
  28.   end repeat
  29. end
  30.  
  31. on buildwordlist pStartAttrib, pEndAttrib, pName, pThisAEpis, pFresh
  32.   hputmsg("buildwordlist>******** Build Full Text Index")
  33.   set vBeginShortCastMem to the number of cast "LU_A_ENCY"
  34.   set vEndShortCastMem to the number of cast "LU_Z_ENCY"
  35.   set vtempList to [:]
  36.   set hold to []
  37.   set vCurrentList to [:]
  38.   set gEntireNameList to [:]
  39.   setupFTindexS()
  40.   if pFresh = 0 then
  41.     set gFTindexS to hReadInList(pName)
  42.   end if
  43.   sort(gFTindexS)
  44.   set gEntireNameList to hMakeListFromCast(vBeginShortCastMem, vEndShortCastMem)
  45.   set gEntireNameList to value(gEntireNameList)
  46.   if pThisAEpis = 1 then
  47.     set gEntireNameList to hThisIsAnEpisGuideVal(gEntireNameList)
  48.   end if
  49.   if voidp(gEntireNameList) then
  50.     hputmsg("this list is messedup")
  51.   end if
  52.   sort(gEntireNameList)
  53.   set vCurrentList to value(vCurrentList)
  54.   sort(vCurrentList)
  55.   repeat with vCountCastMem = pStartAttrib to pEndAttrib
  56.     set vCurrentList to the text of cast vCountCastMem
  57.     set vCurrentList to value(vCurrentList)
  58.     sort(vCurrentList)
  59.     put getPropAt(vCurrentList, 1) into field "searchtextcandidate"
  60.     hMiniFind()
  61.     hscanforwords()
  62.     repeat with n = 2 to count(vCurrentList)
  63.       hStepNext()
  64.       hscanforwords()
  65.     end repeat
  66.     hAlphWrite(pName)
  67.   end repeat
  68.   put "FINISHED"
  69. end
  70.  
  71. on setupFTindexS
  72.   hputmsg("******** setup the global full text list")
  73.   set gFTindexS to [:]
  74.   sort(gFTindexS)
  75.   initexclusionlist1()
  76.   initexclusionlist2()
  77. end
  78.  
  79. on hTestAttForShortNames pATTBEGIN, pATTEND
  80.   set vBeginShortCastMem to the number of cast "LU_A_ENCY"
  81.   set vEndShortCastMem to the number of cast "LU_Z_ENCY"
  82.   set vLUlist to hMakeListFromCast(vBeginShortCastMem, vEndShortCastMem)
  83.   set vTheseareMissing to hSpitOutShortNames(pATTBEGIN, pATTEND, vLUlist)
  84.   hputmsg(RETURN)
  85.   writeIt(string(vTheseareMissing), "MISSING.TXT")
  86.   hputmsg(vTheseareMissing)
  87. end
  88.  
  89. on hSpitOutShortNames pBegin, pend, pList
  90.   hputmsg(">hSpitOutShortNames begins.")
  91.   set vMissingList to []
  92.   set pList to value(pList)
  93.   repeat with vCountCastMem = pBegin to pend
  94.     set vAttList to value(the text of cast vCountCastMem)
  95.     repeat with x = 1 to count(vAttList)
  96.       set vLongName to getPropAt(vAttList, x)
  97.       set vPos to getPos(pList, vLongName)
  98.       if vPos <> 0 then
  99.         set vHereIstheShortName to getPropAt(pList, vPos)
  100.         hputmsg("O.K.")
  101.         next repeat
  102.       end if
  103.       addAt(vMissingList, vLongName)
  104.       hputmsg(RETURN & "hSpitOutShortNames   > MISSING>" && vLongName)
  105.     end repeat
  106.     put vMissingList
  107.   end repeat
  108.   hputmsg("done.")
  109.   put vMissingList
  110.   return vMissingList
  111. end
  112.  
  113. on hAlphWrite thisname
  114.   set gAlphText to [:]
  115.   set gtheText to [:]
  116.   repeat with p = charToNum("A") to charToNum("Z")
  117.     set gtheText to gFTindexS
  118.     sort(gtheText)
  119.     set vstartHere to numToChar(p)
  120.     set vendHere to numToChar(p + 1)
  121.     repeat with n = findPosNear(gtheText, vstartHere) to findPosNear(gtheText, vendHere) - 1
  122.       addProp(gAlphText, getPropAt(gtheText, n), getAt(gtheText, n))
  123.     end repeat
  124.     writeIt(gAlphText, thisname & numToChar(p))
  125.     set gAlphText to [:]
  126.   end repeat
  127. end
  128.  
  129. on writeIt thisString, thisname
  130.   set gtheText to [:]
  131.   set gWriteObject to FileIO(mnew, "write", the pathName & thisname)
  132.   set gtheText to thisString
  133.   set newText to value(gtheText)
  134.   set reallyText to string(newText)
  135.   gWriteObject(mWriteString, reallyText)
  136.   gWriteObject(mdispose)
  137.   hputmsg("Wrote a file named " & thisname & "******************" & RETURN)
  138. end
  139.  
  140. on hReadIt thisname
  141.   set gTheFile to [:]
  142.   set gReadObject to FileIO(mnew, "read", the pathName & thisname)
  143.   hputmsg("the pathname&thisName =" & the pathName & thisname)
  144.   set gTheFile to gReadObject(mReadLine)
  145.   gReadObject(mdispose)
  146.   hputmsg("Read a file named " & thisname & "******************" & RETURN)
  147.   return gTheFile
  148. end
  149.  
  150. on hscanforwords
  151.   set entryname to the text of field "searchtextcandidate"
  152.   hputmsg("the entryname is" && entryname)
  153.   set nextword to EMPTY
  154.   set Wrdnum to 1
  155.   set listed to 0
  156.   set maxwrds to the number of words in field "F1"
  157.   set entryname to hChangeOneEntry(entryname, gEntireNameList)
  158.   hputmsg("after  entryname =" && entryname)
  159.   repeat while Wrdnum <= maxwrds
  160.     set nextword to hZapped(word Wrdnum of field "F1")
  161.     set vFirstChar to hCapitalize(chars(nextword, 1, 1))
  162.     set nextword to vFirstChar & chars(nextword, 2, length(nextword))
  163.     if not getOne(gdontfind1, nextword) then
  164.       if not getOne(gdontfind2, nextword) then
  165.         set currvalue to getaProp(gFTindexS, nextword)
  166.         if not voidp(currvalue) then
  167.           set prevlist to getaProp(currvalue, entryname)
  168.           if not voidp(prevlist) then
  169.             put "," & Wrdnum after prevlist
  170.             setProp(currvalue, entryname, prevlist)
  171.           else
  172.             addProp(currvalue, entryname, Wrdnum)
  173.           end if
  174.           setProp(gFTindexS, nextword, currvalue)
  175.         else
  176.           set templist to [:]
  177.           setaProp(templist, entryname, Wrdnum)
  178.           addProp(gFTindexS, nextword, templist)
  179.         end if
  180.       end if
  181.     end if
  182.     set Wrdnum to Wrdnum + 1
  183.     set listed to 0
  184.   end repeat
  185. end
  186.  
  187. on hZapped x
  188.   if voidp(x) then
  189.     return 
  190.   end if
  191.   set x to hZapThroughOut(x, 40)
  192.   set x to hZapThroughOut(x, 91)
  193.   set x to hZapThroughOut(x, 41)
  194.   set x to hZapThroughOut(x, 93)
  195.   set x to hZapThroughOut(x, 59)
  196.   set x to hZapThroughOut(x, 58)
  197.   set x to hZapBegin(x, 32)
  198.   set x to hZapBegin(x, 210)
  199.   set x to hZapBegin(x, 39)
  200.   set x to hZapBegin(x, 45)
  201.   set x to hZapBegin(x, 212)
  202.   set x to hZapEnd(x, 32)
  203.   set x to hZapEnd(x, 211)
  204.   set x to hZapEnd(x, 44)
  205.   set x to hZapEnd(x, 46)
  206.   set x to hZapEnd(x, 39)
  207.   set x to hZapEnd(x, 213)
  208.   set x to hZapEnd(x, 33)
  209.   set x to hZapEnd(x, 63)
  210.   set x to hZapSpecialCase(x)
  211.   return x
  212. end
  213.  
  214. on hZapSpecialCase vEntry
  215.   if charToNum(char length(vEntry) - 1 of vEntry) = 213 then
  216.     if charToNum(char length(vEntry) of vEntry) = 115 then
  217.       delete char length(vEntry) of vEntry
  218.       delete char length(vEntry) of vEntry
  219.     end if
  220.   end if
  221.   return vEntry
  222. end
  223.  
  224. on hSaveProperties
  225.   set hold to []
  226.   repeat with n = 1 to count(gFTindexS)
  227.     set vhold to getPropAt(gFTindexS, n)
  228.     append(hold, vhold)
  229.   end repeat
  230.   return hold
  231. end
  232.  
  233. on hReadInList vFileName
  234.   set gShortLongName to [:]
  235.   set gEntireNameList to [:]
  236.   repeat with vVar = charToNum("A") to charToNum("Z")
  237.     set vVarChar to numToChar(vVar)
  238.     set gShortLongName to hReadIt(vFileName & vVarChar)
  239.     set gShortLongName to value(gShortLongName)
  240.     if not objectp(gShortLongName) then
  241.     end if
  242.     set p to 1
  243.     repeat with p = p to count(gShortLongName)
  244.       addProp(gEntireNameList, getPropAt(gShortLongName, p), getAt(gShortLongName, p))
  245.     end repeat
  246.   end repeat
  247.   return gEntireNameList
  248. end
  249.  
  250. on hReadInEntry vFileName, list
  251.   set vShortLongName to [:]
  252.   set vShortLongName to hReadIt(vFileName)
  253.   set vShortLongName to value(vShortLongName)
  254.   if not objectp(vShortLongName) then
  255.   end if
  256.   repeat with p = 1 to count(vShortLongName)
  257.     addProp(list, getPropAt(vShortLongName, p), getAt(vShortLongName, p))
  258.   end repeat
  259.   return list
  260. end
  261.  
  262. on hChangeOneEntry vEntryName, vthisList
  263.   set vthisList to value(vthisList)
  264.   set vFindWhere to getPos(vthisList, vEntryName)
  265.   if vFindWhere <> 0 then
  266.     hputmsg(">hChangeOneEntry got pos =" && vFindWhere && "for" && vEntryName)
  267.     set vValue to getPropAt(vthisList, vFindWhere)
  268.   else
  269.     set vValue to hMakeEmergencySrtNm(vEntryName)
  270.   end if
  271.   return vValue
  272. end
  273.  
  274. on hMakeEmergencySrtNm pNtryNm
  275.   set vCleanLongName to hZapMod(pNtryNm)
  276.   set vLength to length(vCleanLongName)
  277.   set vShortName to "X" & char 1 to 3 of vCleanLongName & char vLength - 1 to vLength of vCleanLongName
  278.   if length(vShortName) < 6 then
  279.     set vDiff to 6 - length(vShortName)
  280.     repeat with n = 1 to vDiff
  281.       set vAdd to vAdd & "_"
  282.     end repeat
  283.     set vShortName to vShortName & vAdd
  284.   end if
  285.   hputmsg("YO! we made ‚Ä¢>" & vShortName & "<‚Ä¢ out of " & pNtryNm)
  286.   if hFileIsHere(the pathName & "New Short Names") then
  287.     set vL to hReadIt("New Short Names")
  288.   end if
  289.   set vL to vL & vShortName & ":" & pNtryNm & ", "
  290.   hputmsg("Sending" && vL && "to file.")
  291.   hWriteFile(vL, "New Short Names")
  292.   return vShortName
  293. end
  294.  
  295. on hWriteFile pthisString, pthisName
  296.   set vWriteObject to FileIO(mnew, "write", the pathName & pthisName)
  297.   vWriteObject(mWriteString, pthisString)
  298.   vWriteObject(mdispose)
  299.   hputmsg("Wrote a file named " & pthisName & RETURN)
  300. end
  301.  
  302. on hZapMod pN
  303.   if voidp(pN) then
  304.     return 
  305.   end if
  306.   set pN to hZapThroughOut(pN, 40)
  307.   set pN to hZapThroughOut(pN, 91)
  308.   set pN to hZapThroughOut(pN, 41)
  309.   set pN to hZapThroughOut(pN, 93)
  310.   set pN to hZapThroughOut(pN, 59)
  311.   set pN to hZapThroughOut(pN, 58)
  312.   set pN to hZapThroughOut(pN, 32)
  313.   set pN to hZapThroughOut(pN, 210)
  314.   set pN to hZapThroughOut(pN, 39)
  315.   set pN to hZapThroughOut(pN, 45)
  316.   set pN to hZapThroughOut(pN, 212)
  317.   set pN to hZapThroughOut(pN, 211)
  318.   set pN to hZapThroughOut(pN, 44)
  319.   set pN to hZapThroughOut(pN, 46)
  320.   set pN to hZapThroughOut(pN, 39)
  321.   set pN to hZapThroughOut(pN, 213)
  322.   set pN to hZapThroughOut(pN, 33)
  323.   set pN to hZapThroughOut(pN, 63)
  324.   set pN to hZapThroughOut(pN, 142)
  325.   set pN to hZapThroughOut(pN, 137)
  326.   set pN to hZapSpecialCase(pN)
  327.   return pN
  328. end
  329.